<?php
	if(isset($_GET["file"])):
		$data = [
			[
				"name"=>$_GET["file"]
			]
		];
	elseif(isset($_GET["s"]) && isset($_GET["e"]) && is_numeric($_GET["s"])  && is_numeric($_GET["s"])  && $_GET["s"]<=$_GET["e"] ):
		$data = [];
		for($i = $_GET["s"]; $i<$_GET["e"]+1; $i++) {
			$data[] = ["name"=>$i.".mp4"];
		}
	else:
		echo "error";
		exit;
	endif;
?>

<!doctype html>
<html lang="en">
<head>
    <title>vGift</title>
	<meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
	
	<link href="favicon.ico" rel="shortcut icon">

	<!--[if lt IE 9]>
      <script src="js/Respond-1.4.2/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">
    	.qrcode{
    		float: left;
    		padding:20px;
    	}
    </style>
</head>
<body>
	
	<div id="qrcode_box"></div>

	<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="http://cdn.staticfile.org/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
	<script type="text/javascript">
		var domain = window.location.origin + window.location.pathname;
		domain = domain.substr(0,domain.length-10)+"index.php";

		<?php foreach ($data as $value):?>
			var div = $("<div class='qrcode' />");
			var qrcodeText = domain+"?file=<?=$value['name']?>";
			console.log(qrcodeText);
			div.qrcode({width: 128,height: 128,text: qrcodeText});
			$("#qrcode_box").append(div);
		<?php endforeach;?>		
	</script>
</body>
</html>